package com.example.demo.controller;

import com.example.demo.domain.MyUser;
import com.example.demo.service.MyService;
import com.knife.cache.redis.service.UserCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA.
 *
 * @author： 76875
 * @date： 2022/1/6 星期四 20:04
 * @description：
 * @modifiedBy：
 * @version: 1.0
 */
@RestController
public class MyController {

    @Autowired
    private MyService myService;


    @Autowired
    private UserCache userCache;

    @GetMapping("/test")
    public String test(){
        return myService.batchInsertUser();
    }


    @GetMapping("/{userId}")
    public MyUser getUser(@PathVariable Long userId){
        MyUser condition = new MyUser();
        condition.setId(userId);
        return userCache.getValue(condition);
    }
}
